<%@ Page Language="C#" AutoEventWireup="false" MasterPageFile="~/Screens/ScreenMasterPage.master" %>
<asp:Content ContentPlaceHolderID="Head" runat="server">

	<script type="text/javascript">
		var subtitlesController = osh.getPlugin("SubtitlesController");
		function window::onload()
		{
			if(subtitlesController != null)
				subtitlesController.attachEvent("onchange", this.onChange);
			screen.onKey.attach(this, this.onKey);
		}
		function window::onunload()
		{
			if(subtitlesController != null)
				subtitlesController.detachEvent("onchange", this.onChange);
			screen.onKey.detach(this, this.onKey);
		}
		function onChange(event)
		{
			var subtitleInfo = event.subtitleInfo;
			if(subtitleInfo == null)
				return;

			for(var i = 0; i < subtitleInfo.lines.length; i++)
			{
				var lineElement = document.getElementById("subtitleLine" + i);
				if(lineElement != null)
				{
					var html = subtitleInfo.lines[i].text;
					if(subtitleInfo.lines[i].color != 0xFFFFFF)
					{
						var color = (subtitleInfo.lines[i].color + 0x1000000).toString(16).substr(1);
						html = "<span style='color: #" + color + "'>" + html + "</span>";
					}
					if(subtitleInfo.lines[i].isBold)
						html = "<b>" + html + "</b>";
					lineElement.innerHTML = html;
				}
			}
			/*
			if(subtitleInfo.lines.length == 0)
			{
				subtitleLine0.innerHTML = "";
				subtitleLine1.innerHTML = "";
			}
			else if(subtitleInfo.lines.length == 1)
				subtitleLine1.innerHTML = "";
			*/

			osh.refresh();
		}
		function onKey(sender, event)
		{
			if(subtitlesController != null)
			{
				if(event.keyCode == window.top.Keys.VK_LEFT)
					subtitlesController.delay = subtitlesController.delay - 250;
				else if(event.keyCode == window.top.Keys.VK_RIGHT)
					subtitlesController.delay = subtitlesController.delay + 250;
			}
		}
	</script>

</asp:Content>
<asp:Content ContentPlaceHolderID="Body" runat="server">

	<div id="InfoBlock">
		<div id="subtitleLine0" class="subtitleLine"></div>
		<div id="subtitleLine1" class="subtitleLine"></div>
	</div>

</asp:Content>
